package com.springsecirtytest.activiti1.controller;

import com.springsecirtytest.activiti1.mapper.ActivitiMaper;
import com.springsecirtytest.activiti1.util.AjaxResponse;
import com.springsecirtytest.activiti1.util.GlobalConfig;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
public class UserController {

    @Autowired
    private ActivitiMaper activitiMaper;

    @GetMapping("getUsers")
    public AjaxResponse getUsers(){

        try {

            List<HashMap<String, Object>> userList = activitiMaper.selectUser();

            return AjaxResponse.ajaxData(GlobalConfig.ResponseCode.SUCCESS.getCode(),
                    GlobalConfig.ResponseCode.SUCCESS.getDesc(), userList);


        } catch (Exception e) {
            return AjaxResponse.ajaxData(GlobalConfig.ResponseCode.ERROR.getCode(),
                    "获取用户列表失败", e.toString());
        }

        }
}
